<?php

abstract class AController extends CController
{
	// ------------------------------------------------------------------------------------
	/**
	 * Runs the named action.
	 * @param string $actionID action ID
	 */
	public function run($actionID)
	{
		if(empty($actionID))
		{
			$actionID = 'index';
		}

		$actionName = 'action' . $actionID;
		if(!method_exists($this, $actionName))
		{
			$this->missingAction($actionID);
		}

		$url = explode('/', Yii::app()->request->getPathInfo());
		$id = array_pop(explode('/', $this->getID()));

		if(isset($url[0]) && $id == $url[0])
		{
			array_splice($url, 0, 1);
		}

		if(isset($url[0]) && $actionID == $url[0])
		{
			array_splice($url, 0, 1);
		}

		call_user_func_array(array($this, $actionName), $url);
	}

	// ------------------------------------------------------------------------------------
}